package com.atguigu.spzx.model.entity.user;

import com.atguigu.spzx.model.entity.system.SysUser;

/**
 * 创建一个本地线程存储userInfo用户信息
 * @author Mahone
 */
public class AuthContextUtil {

    final static ThreadLocal<UserInfo> threadLocal = new ThreadLocal<>();

    public static UserInfo getUserInfo(){
        // 返回当前用户信息
        UserInfo userInfo = threadLocal.get();
        return userInfo;
    }

    public static void setUserInfo(UserInfo userInfo){
        // 存入当前用户信息
        threadLocal.set(userInfo);
    }

    public static void clear(){
        threadLocal.remove();
    }
}
